﻿using Gengens.Disk.Entity;

namespace Gengens.Disk.Repository
{
    public interface IBaseRepository<Model> where Model : BaseModel<Model>
    {
        #region 查询

        Model Find(Guid id);
        Task<Model> FindAsync(Guid id);
        List<Model> FindAll();
        Task<List<Model>> FindAllAsync();
        List<Model> Select(Func<Model,bool> whereFunc);
        Task<List<Model>> SelectAsync(Func<Model,bool> whereFunc);
        List<Model> PageSelect(int pageSize, int pageIndex, Func<Model, bool> whereFunc);
        Task<List<Model>> PageSelectAsync(int pageSize, int pageIndex, Func<Model, bool> whereFunc);

        #endregion

        #region 新增

        Model Insert(Model model);
        Task<Model> InsertAsync(Model model);
        void InsertRange(List<Model> models);
        Task InsertRangeAsync(List<Model> models);

        #endregion

        #region 更新

        void Update(Model model);
        void UpdateRange(List<Model> models);

        #endregion

        #region 删除

        void Delete(Model model);

        void DeleteRange(List<Model> models);

        #endregion

        #region 保存

        void SaveChanges();
        Task SaveChangesAsync();

        #endregion

        Task<int> ExecuteSqlRawAsync(string sql, params object[] args);
    }
}
